<?php

declare(strict_types=1);

namespace app\controller\manage;

use app\BaseController;
use app\service\platform\PlatformService;

class Platform extends BaseController
{
    protected $platformServer;

    public function initialize()
    {
        $this->platformServer = make(PlatformService::class);
    }
    /**
     * 协议或文章列表
     */
    public function agreementList()
    {
        return $this->success($this->platformServer->agreementList($this->paging()));
    }
    /**
     * 协议或文章编辑
     */
    public function agreementEdit()
    {
        $data = $this->request->post();
        $this->validate($data, [
            'name|协议或文章标题' => 'require|length:1,80',
            'mark|协议或文章标识' => 'require|length:1,30',
            'sort|序号' => 'egt:0|lt:255',
            'content|协议或文章内容' => 'require|min:1',
        ]);
        $res = $this->platformServer->agreementEdit($data, (int) $data['id']);
        return $res ? $this->success() : $this->error('保存失败');
    }
    /**
     * 客户反馈列表
     */
    public function feedbackList()
    {
        return $this->success($this->platformServer->feedbackList($this->paging()));
    }
    /**
     * 客户反馈详情
     */
    public function feedbackInfo()
    {
        $param = $this->request->get();
        return $this->success($this->platformServer->feedbackInfo((int) $param['id']));
    }
}
